#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    long long n,m,L,V,d[n],v[n],a[n],xi[m],c=0;
    cin>>n>>m>>L>>V;
    for(long long i=0;i<n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(long long i=0;i<m;i++){
        cin>>xi[i];
    }
    for(long long i=0;i<n;i++){
        if(a[i]=0){
            if(v[i]>V){
                c++;
                continue;
            }
        }
    }
       cout<<c<<a[n];
    return 0;
}
